#pragma once
#include <map>
#include "CommonDef.h"
class SessionModel : public Singleton<SessionModel>
{
public:
    SessionModel();

    ~SessionModel();

public:
    bool addSessionPlayer(Postion ps, const SessionPlayer& sessionPlayer);

    void removeSessionPlayer(Postion ps);

    SessionPlayer* getSessionPlayer();

    const SessionPlayer& getSessionPlayerByPs(Postion ps) const;

    void setHostPlayer(Postion ps);

    const SessionPlayer& getHostPlayerPs() const;

    void setUserPlayer(Postion ps);

    const SessionPlayer& getUserPlayerPs() const;

    void clearData();

private:
    SessionPlayer m_sessionPlayerArry[SessionEnum::MAX_PLAYER_SIZE];
    short m_sessionCunt;
    Postion m_hostPlayerPs;
    Postion m_userPlayerPs;

public:
    void shuffleChess(short maxChessCunt);

    const std::vector<Chess>& getShuffleChess() const;

    void addPlayerChess(Postion ps, const Chess& chess);

    void sortPlayerChess(Postion ps);

    void removePlayerChess(Postion ps, const Chess& chess);

    void removePlayerChessByWeaveChess(Postion ps, const KindChess& weaveChess);

    const std::vector<Chess>& getHandleChessByPs(Postion ps);

    void addOutputChess(Postion ps, const Chess& chess);

    void removeOutputChess(Postion ps, const Chess& chess);

    const std::vector<Chess>& getOutputChessByPs(Postion ps);

    void addWeaveChess(Postion ps, const KindChess& kindChess);

    void updateWeave2XuGang(Postion ps, const Chess& chess);

    const std::vector<KindChess>& getWeaveChessByPs(Postion ps);

    void setShowOffsetPair(ShowOffsetPair* showOffset);

    const ShowOffsetPair* getShowOffsetPair() const;

    bool isChessOver() const;
private:
    std::vector<Chess> m_shuffleChess;
    std::vector<Chess> m_handleChessArry[SessionEnum::MAX_PLAYER_SIZE];
    std::vector<Chess> m_outputChessArry[SessionEnum::MAX_PLAYER_SIZE];
    std::vector<KindChess> m_weaveChessArry[SessionEnum::MAX_PLAYER_SIZE];
    ShowOffsetPair m_showOffsetPair[SessionEnum::MAX_PLAYER_SIZE];

public:
    Postion getTurnerPostion() const;

    void setTurnerPostion(Postion ps);

    bool dispatchChess(Chess& newChess);

    bool dispatchGangChess(Chess& newChess);

    short getSessionCunt() const;

    size_t getDispatchOffset() const;

    size_t getGangOffset() const;

private:
    Postion m_turnerPlayerPs;
    size_t m_dispatchOffset;
    size_t m_gangOffset;
private:
    void clearSessionData();
};

